package com.mypackage.LocationPattern;

import android.content.ContentValues;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import static com.mypackage.LocationPattern.Constants.*;

public class GeoStamp {
	
	private final static String[] daysOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
	
	private double latitude;
	private double longitude;
	private int hour;
	private int minute;
	private int day;
	private LocationData locations;
	
	
	public GeoStamp(double latitude, double longitude, int hour, int minute, int day){
		
		this.latitude = latitude;
		this.longitude = longitude;
		this.hour = hour;
		this.minute = minute;
		this.day = day;
		
		
		}

	
	public boolean save(){
		SQLiteDatabase db = locations.getWritableDatabase();
		ContentValues values = new ContentValues();
		values.put(LATITUDE, latitude);
		values.put(LONGITUDE, longitude);
		values.put(HOUR, hour);
		values.put(MINUTE, minute);
		
		try{
			db.insertOrThrow(TABLE_NAME, null, values);
		}catch(SQLException e){
			return false;
		}
		return true;
	}
	
	/**
	 * @return the latitude
	 */
	public double getLatitude() {
		return latitude;
	}

	/**
	 * @param latitude the latitude to set
	 */
	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}

	/**
	 * @return the longitude
	 */
	public double getLongitude() {
		return longitude;
	}

	/**
	 * @param longitude the longitude to set
	 */
	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}

	/**
	 * @return the hour
	 */
	public int getHour() {
		return hour;
	}

	/**
	 * @param hour the hour to set
	 */
	public void setHour(int hour) {
		this.hour = hour;
	}

	/**
	 * @return the minute
	 */
	public int getMinute() {
		return minute;
	}

	/**
	 * @param minute the minute to set
	 */
	public void setMinute(int minute) {
		this.minute = minute;
	}
	
	
	/**
	 * @return the day
	 */
	public int getDay() {
		return day;
	}

	/**
	 * @param day the day to set
	 */
	public void setDay(int day) {
		this.day = day;
	}

	@Override
	public String toString(){
		String s = "";
		s += "latitude: " + this.latitude;
		s += "\n" + "longitude: " + this.longitude;
		s += "\n" + "time: " + this.hour + ":" + this.minute + " on " + daysOfWeek[day];
		
		return s;
	}

}
